package com.example.demospringboot.batch.reader;

import org.springframework.batch.item.database.JdbcCursorItemReader;
import org.springframework.jdbc.core.BeanPropertyRowMapper;

import com.alibaba.druid.pool.DruidDataSource;
import com.example.demospringboot.entity.User;

/**
 * @author chenlei
 * @date 2019-12-12
**/
public class MyItemReader extends JdbcCursorItemReader<User>{
	
	public MyItemReader(DruidDataSource datasource){
		super.setSql("select * from tb_user");
        super.setDataSource(datasource);
        BeanPropertyRowMapper<User> RowMapper = new BeanPropertyRowMapper<User>();
        RowMapper.setMappedClass(User.class);
        super.setRowMapper(RowMapper);
	}

}
